package com.atguigu.stgy.common.config;

import com.atguigu.stgy.common.converter.BaseTypeEnumConverterFactory;
import jakarta.annotation.Resource;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

public class StgyWebMvcConfigurer implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowCredentials(true)
                .allowedOriginPatterns("*")
                .allowedHeaders("*")
                .allowedMethods("*");
    }



    @Resource
    BaseTypeEnumConverterFactory factory;
    //枚举转换器工厂
    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverterFactory(factory);
    }


}
